package com.example.goodpet.home.homeRecommend.adapter.viewholder;

import android.content.Context;
import android.content.Intent;
import android.view.View;
import android.widget.AdapterView;
import android.widget.GridView;
import android.widget.Toast;

import androidx.recyclerview.widget.RecyclerView;

import com.example.goodpet.R;
import com.example.goodpet.activity.MainChannelActivity;
import com.example.goodpet.bean.MainChannelInfoDTO;
import com.example.goodpet.home.homeRecommend.adapter.adapters.MainChannelAdapter;
import com.example.goodpet.home.homeRecommend.bean.ResultBeanData;

import java.util.List;

public class MainChannelViewHolder extends RecyclerView.ViewHolder {
    private Context mContext;
    private GridView gv_channel;
    private MainChannelAdapter adapter;

    public MainChannelViewHolder(Context mContext, View itemView) {
        super(itemView);
        this.mContext=mContext;
        gv_channel= itemView.findViewById(R.id.gv_channel_main);

        //设置item的点击事件
        gv_channel.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView parent, View view, int position, long id) {
                Intent intent=new Intent(mContext, MainChannelActivity.class);
                intent.putExtra("mainChannelId",position);
                mContext.startActivity(intent);
//                Toast.makeText(mContext, "第"+position+"个图标被点击了", Toast.LENGTH_SHORT).show();
            }
        });
    }


    public void setData(List<MainChannelInfoDTO> mainChannelInfo) {
        adapter=new MainChannelAdapter(mContext,mainChannelInfo);
        gv_channel.setAdapter(adapter);
    }
}
